package com.yeyks.commonReference.service.hotel.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeyks.commonReference.service.hotel.HotelDeveloperRelationService;
import com.yeyks.hotel.dal.domain.HotelDeveloperRelation;
import com.yeyks.hotel.dal.dao.HotelDeveloperRelationMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 酒店开发商关系 服务实现类
 * </p>
 *
 * @author yun
 * @since 2019-08-23
 */
@Service
public class HotelDeveloperRelationServiceImpl extends ServiceImpl<HotelDeveloperRelationMapper, HotelDeveloperRelation> implements HotelDeveloperRelationService {

    /**
     * 通过酒店账户id和类型查询酒店开发商关系对象
     *
     * @param accountId 酒店账户id
     * @param type      类型
     * @param vipType   vip类型,1大V，2小V
     * @return
     */
    @Override
    public HotelDeveloperRelation selectByAccountIdAndType(Integer accountId, Integer type, Integer vipType) {
        return baseMapper.selectOne(new QueryWrapper<HotelDeveloperRelation>()
                .eq(HotelDeveloperRelation.ACCOUNT_ID, accountId)
                .eq(HotelDeveloperRelation.TYPE, type)
                .eq(HotelDeveloperRelation.VIP_TYPE, vipType)
                .last("limit 1"));
    }

    /**
     * 通过运营商账户id和运营商类型以及会员卡类型查询酒店id集合
     *
     * @param accountId
     * @param type
     * @param vipFlag
     * @return
     */
    @Override
    public List<Integer> selectHotelIdsByAccountIdAndType(Integer accountId, Integer type, Integer vipFlag) {
        return baseMapper.selectHotelIdsByAccountIdAndType(accountId, type, vipFlag);
    }
}
